﻿using Frameworks;
using Network.FrameSync;
using Network.FrameSync.Server;
using System.Collections.Generic;

namespace Server
{
    public class XJGameManager : Singleton<XJGameManager>
    {
        private FSPManager _fsp;
        private FSPGame _fspGame;

        private XJGameManager() { }

        public override void OnSingletonInit()
        {
            base.OnSingletonInit();
        }

        public override void Dispose()
        {
            _fsp.Clean();

            base.Dispose();
        }

        public void Init(FSPManager fsp)
        {
            _fsp = fsp;
        }

        public void CreateGame(GameServerStartParam param)
        {
            _fspGame = _fsp.CreateGame(param.roomId, param.authId);

            param.listPlayerFSPSessionId = _fsp.AddPlayer(param.roomId, param.listPlayerId);

            FSPParam fspParam = _fsp.GetParam();
            fspParam.authId = param.authId;
            Client.OnlineManager.Instance.Net.Rpc.Invoke("OnCreateGame", fspParam, param);
        }
    }
}